﻿using System;
using System.Collections.Generic;
using Xenta.Entities;

namespace Xenta.Plugins
{
    /// <summary>
    /// Exposes the payment processor interface.
    /// </summary>
    public interface IPaymentProcessor : IPlugin
    {
        /// <summary>
        /// Determines, if the payment processor is allowed to be used to pay an invoice.
        /// </summary>
        /// <param name="invoice">The invoice.</param>
        /// <returns>true if allowed; otherwise false.</returns>
        bool CanApplyTo(InvoiceEntity invoice);

        /// <summary>
        /// Calculates the handling fee.
        /// </summary>
        /// <param name="invoice">The invoice.</param>
        /// <param name="paymentAmount">The payment amount.</param>
        /// <returns>The handling fee.</returns>
        decimal CalcHandlingFee(InvoiceEntity invoice, decimal paymentAmount);

        /// <summary>
        /// Voids the payment.
        /// </summary>
        /// <param name="payment">The payment.</param>
        /// <param name="comment">When this method return, contains a string comment.</param>
        /// <returns>The payment attributes or null.</returns>
        IDictionary<String, String> Void(PaymentEntity payment, out string comment);

        /// <summary>
        /// Places the payment.
        /// </summary>
        /// <param name="payment">The payment.</param>
        /// <param name="comment">When this method return, contains a string comment.</param>
        /// <returns>The payment attributes or null.</returns>
        IDictionary<String, String> Place(PaymentEntity payment, out string comment);

        /// <summary>
        /// Refunds the payment.
        /// </summary>
        /// <param name="payment">The payment.</param>
        /// <param name="comment">When this method return, contains a string comment.</param>
        /// <returns>The payment attributes or null.</returns>
        IDictionary<String, String> Refund(PaymentEntity payment, out string comment);

        /// <summary>
        /// Authorizes the payment.
        /// </summary>
        /// <param name="payment">The payment.</param>
        /// <param name="comment">When this method return, contains a string comment.</param>
        /// <returns>The payment attributes or null.</returns>
        IDictionary<String, String> Authorize(PaymentEntity payment, out string comment);

        /// <summary>
        /// Captures the payment.
        /// </summary>
        /// <param name="payment">The payment.</param>
        /// <param name="comment">When this method return, contains a string comment.</param>
        /// <returns>The payment attributes or null.</returns>
        IDictionary<String, String> Capture(PaymentEntity payment, out string comment);
    }
}
